/*
 * Vertex CLASS TEMPLATE:
 * Represents concept of plain vertex made up of identification value only.
 *
 * VertexDescriptor CLASS TEMPLATE:
 * Represents concept of stored vertex handler.
 *
 */

#ifndef UNITRAF_GRAPHTRAITS_VERTEX_HPP
#define UNITRAF_GRAPHTRAITS_VERTEX_HPP

#include <graph\IteratorAdaptor.hpp>

namespace unitraf {

namespace graph_traits {

/////////////////////////////////////////////////////////////////////////////
// VERTEX DETAILS

template<class _Property> class Vertex;

// Plain vertex type
template<> class Vertex<no_property_tag> {

  typedef Vertex _myt;

  // Comparator, to introduce strict weak ordering upon set of edges
  friend bool operator<(const _myt& lh, const _myt& rh) {
    return (lh.id_ < rh.id_);
  };

  friend bool operator==(const _myt& lh, const _myt& rh) {
    return (lh.id_ == rh.id_);
  };

  friend bool operator!=(const _myt& lh, const _myt& rh) {
    return !(lh == rh);
  };

  friend __int64 unsigned operator*(const _myt& lh, const _myt& rh) {
    return lh.id_ * rh.id_;
  };

 public:
  /////////////////////////////////////////////////////////////////////////////
  // PUBLIC INTERFACE

  // Vertex identity type
  typedef __int64 unsigned identity_type;

  // CONSTRUCTORS AND INITALIZERS

  Vertex(identity_type id) : id_(id) {};


  // ACCESSORS
      
  identity_type id() const { return id_; };

 private:
  /////////////////////////////////////////////////////////////////////////////
  // REPRESENTATION

  // Vertex ID
  identity_type id_;

};

// Plain vertex implementation
template<class _Property > class Vertex : public Vertex<no_property_tag> { 

  typedef Vertex<no_property_tag> _base;

 public:
  /////////////////////////////////////////////////////////////////////////////
  // PUBLIC INTERFACE

  typedef _Property property_type;

  // CONSTRUCTORS AND INITIALIZERS

  Vertex(identity_type id) 
    : _base(id) {};

  Vertex(const _base& base) 
    : _base(base) {};

  Vertex(identity_type id, const property_type& prop) 
  : _base(id), property_proxy(prop) {};

  ~Vertex() {};

  // REPRESENTATION

  mutable property_type property_proxy;

};

};  // namespace graph_traits

};  // namespace unitraf

#endif  // #ifndef UNITRAF_GRAPHTRAITS_VERTEX_HPP